﻿using System;
using System.Collections.Generic;
using System.Text;

using JigLibX.Physics;
using JigLibX.Collision;
using JigLibX.Math;

using Microsoft.Xna.Framework;



namespace FXnaEngine.Physics
{
    public class QSBody : Body
    {
        private JigLibXActor actor;

        /// <summary>
        /// A combination of all additional forces being placed on this body.
        /// </summary>
        public Vector3 AdditionalForce
        {
            get { return additionalForce; }
        }
        protected Vector3 additionalForce;

        public QSBody(JigLibXActor actor)
            : base()
        {
            this.actor = actor;
            this.additionalForce = Vector3.Zero;
        }

        public void AddAdditionalForce(ref Vector3 force)
        {
            this.additionalForce += force;
        }

        public override void AddExternalForces(float dt)
        {
            ClearForces();

            this.Velocity += (this.additionalForce * dt);

            AddGravityToExternalForce();
        }

        /// <summary>
        /// Called whenever this <see cref="QSBody"/> is set to 'Active'
        /// </summary>
        protected override void Activated()
        {
            this.actor.BodyActivated();
        }

        /// <summary>
        /// Called whenever this <see cref="QSBody"/> is set to 'Inactive'
        /// </summary>
        protected override void Deactivated()
        {
            this.actor.BodyDeactivated();
        }
    }
}
